<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<title>活动评价</title>
<%@include file="/common/wxCommon.jspf"%>
<body ontouchstart>
	<header class="page-header">
		<h1 class="page-title">${party.subject }</h1>
	</header>
	<form method="post" action="${ctx }/weixin/user/party/saveComment.shtml" id="form">
	<input type="hidden" name="partyId" value="${party.id }">
	<input type="hidden" id="starLevel" name="partyAttendFormMap.starLevel" value="0">
	<div class="weui_cells_title">评价内容&nbsp;
	<c:if test="${partyAttend.status eq 1}"><i class="weui_icon_success_no_circle"></i></c:if>
	</div>
	<div class="weui_cells weui_cells_form">
		<div class="weui_cell">
			<div class="weui_cell_bd weui_cell_primary">
				<textarea class="weui_textarea" placeholder="用心评价可以获得更多的积分哦" maxlength="500" rows="5"
					${partyAttend.status eq 1 ? "disabled" : ""} name="partyAttendFormMap.comment">${partyAttend.comment }</textarea>
				<div class="weui_textarea_counter">
					<span>${empty partyAttend.comment ? 0 : fn:length(partyAttend.comment)}</span>/500
				</div>
			</div>
		</div>
		<div class="weui_cell">
			<div class="weui_cell_bd weui_cell_primary">
				<p>
					<i class="comment-star ${partyAttend.starLevel ge 1 ? 'lightstar' : '' }" val="1"></i>
					<i class="comment-star ${partyAttend.starLevel ge 2 ? 'lightstar' : '' }" val="2"></i>
					<i class="comment-star ${partyAttend.starLevel ge 3 ? 'lightstar' : '' }" val="3"></i>
					<i class="comment-star ${partyAttend.starLevel ge 4 ? 'lightstar' : '' }" val="4"></i>
					<i class="comment-star ${partyAttend.starLevel ge 5 ? 'lightstar' : '' }" val="5"></i>
				</p>
			</div>
		</div>
	</div>
	<c:if test="${partyAttend.status eq 0 }">
	<div class="content-padded">
		<button type="submit" class="weui_btn weui_btn_warn">保存</button>
	</div>
	<script type="text/javascript">
		$(".comment-star").click(function(){
			var starLevel = $(this).attr("val");
			$("#starLevel").val(starLevel);
			$(".comment-star").each(function(i,e){
				$(this).removeClass("lightstar");
			});
			$(".comment-star").each(function(i,e){
				if (i < starLevel) {
					$(this).addClass("lightstar");
				}
			});
		});
		
		$(function() {
			
			$("[name='partyAttendFormMap.comment']").keyup(
				function() {
					$(this).parent().find(".weui_textarea_counter").find(
							"span:first").html($(this).val().length);
			});
			
			//jquery form验证
			$("#form").validate({
				ignore: "",
				submitHandler: function(form) {
					form.submit();
				},
				errorPlacement: function(error, element) {
					//验证失败时
					$.toast($(error).text(), "cancel");
				},
				rules: {
					"partyAttendFormMap.starLevel": {required: true, digits: true, range: [1, 5]  }
				},
				messages: {
					"partyAttendFormMap.starLevel" : {
						required: "请选择星级评价",
						digits : "请选择星级评价",
						range : "请选择星级评价"
					}
				}
			});
		});
	</script>
	</c:if>
</body>
</html>